"use strict";
cc._RF.push(module, 'bdec23rTjdDmJu3+w76jxEZ', 'HallHandBookView');
// scripts/HallHandBookView.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("CarConstant"),
    s = t("GlobalUserData"),
    l = t("HallScene"),
    c = t("NativeManager"),
    d = t("Util"),
    h = t("Global"),
    p = t("HandBook"),
    u = cc._decorator,
    f = u.ccclass,
    m = u.property,
    _ = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.arr_starBtns = new Array(5), e.frame_normal = null, e.frame_pressed = null, e.arr_typeBtns = new Array(4), e.frame_itemBtnNormal = null, e.frame_itemBtnPressed = null, e.frame_itemTextPressed = new Array(4), e.frame_itemIconPressed = new Array(4), e.color_white = cc.Color.WHITE, e.color_gray = cc.Color.GRAY, e.node_content = null, e.pfb_item = null, e._curStarBtn = null, e._handBook_arr = [], e.itemIndex = 0, e.starNum = 1, e.weapon_arr = r.Basics_Weapon_Info.concat(r.Basics_preview_weapon_Info), e.itemArr = [r.Basics_Body_Info, e.weapon_arr, r.Basics_Wheel_Info, r.Basics_Tools_Info], e.btnState = {
      btnNode: null,
      textIcon: null,
      icon: null
    }, e;
  }

  return n(e, t), e.prototype.onLoad = function () {
    s["default"].popup = this.node, console.log(this.itemArr);
  }, e.prototype.start = function () {
    for (var t = 0; t < this.arr_starBtns.length; t++) {
      this.arr_starBtns[t].getChildByName("text").color = this.color_gray;
    }

    this.showHandBook(this.itemArr[this.itemIndex]), this.setStarBtnStatus(this.arr_starBtns[0], this.frame_pressed, this.color_white), this.setTypeBtnStatus(this.arr_typeBtns[0], 0), d.Util.hideSingleCustomAd(), s["default"].isIllustratedBookView = !0, d.Util.hideNativeGridAd();
  }, e.prototype.onEnable = function () {
    d.Util.is_233() ? c["default"].instance.showFullVideoAd() : d.Util.showInterstitialAd(null, null, function () {
      d.Util.show_matrixAd();
    });
  }, e.prototype.onDisable = function () {
    d.Util.hide_matrixAd();
  }, e.prototype.onBtnRefreshStarNum = function (t, e) {
    this._curStarBtn !== t.currentTarget && (this._curStarBtn && this.setStarBtnStatus(this._curStarBtn, this.frame_normal, this.color_gray), this.setStarBtnStatus(t.currentTarget, this.frame_pressed, this.color_white), this.setStarNum(Number(e)));
  }, e.prototype.onBtnRefreshItem = function (t, e) {
    this.itemIndex != Number(e) && (this.itemIndex = Number(e), this.showHandBook(this.itemArr[this.itemIndex]), this.setTypeBtnStatus(this.arr_typeBtns[this.itemIndex], this.itemIndex));
  }, e.prototype.setStarNum = function (t) {
    if (null != this._handBook_arr) {
      for (var e = 0; e < this._handBook_arr.length; e++) {
        this._handBook_arr[e].setStarNum(t);
      }

      this.starNum = t;
    }
  }, e.prototype.setStarBtnStatus = function (t, e, o) {
    t.getComponent(cc.Sprite).spriteFrame = e, t.getChildByName("text").color = o, this._curStarBtn = t;
  }, e.prototype.setTypeBtnStatus = function (t, e) {
    null != this.btnState.btnNode && (this.btnState.btnNode.getComponent(cc.Sprite).spriteFrame = this.frame_itemBtnNormal, this.btnState.btnNode.getChildByName("text").getComponent(cc.Sprite).spriteFrame = this.btnState.textIcon, this.btnState.btnNode.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.btnState.icon), this.btnState.btnNode = t, this.btnState.textIcon = t.getChildByName("text").getComponent(cc.Sprite).spriteFrame, this.btnState.icon = t.getChildByName("icon").getComponent(cc.Sprite).spriteFrame, t.getComponent(cc.Sprite).spriteFrame = this.frame_itemBtnPressed, t.getChildByName("text").getComponent(cc.Sprite).spriteFrame = this.frame_itemTextPressed[e], t.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.frame_itemIconPressed[e];
  }, e.prototype.onBtnClose = function () {
    s["default"].popup = null, this.node.destroy(), d.Util.showSingleCustomAd(), s["default"].isIllustratedBookView = !1, cc.find("Canvas").getComponent(l["default"]).comebackshow();
  }, e.prototype.showHandBook = function (t) {
    for (var e = 0, o = 0; o < 3; o++) {
      for (var i = 0; i < t.length; i++) {
        if ((a = d.Util.deepCopyJson(t[i])).type == r.Basics_Items_Type.body) {
          if (o == h.Quality.Legendary) continue;
        } else if (o != a.quality) continue;

        if (a.star = this.starNum, a.quality = o, this._handBook_arr[e]) this._handBook_arr[e].node.active = !0, this._handBook_arr[e].updata(a);else {
          var n = cc.instantiate(this.pfb_item);
          this.node_content.addChild(n), n.getComponent(p["default"]).updata(a), this._handBook_arr.push(n.getComponent(p["default"]));
        }
        e++;
      }
    }

    for (i = e; i < this._handBook_arr.length; i++) {
      var a;
      (a = this._handBook_arr[i]).node.active = !1;
    }
  }, a([m([cc.Node])], e.prototype, "arr_starBtns", void 0), a([m(cc.SpriteFrame)], e.prototype, "frame_normal", void 0), a([m(cc.SpriteFrame)], e.prototype, "frame_pressed", void 0), a([m([cc.Node])], e.prototype, "arr_typeBtns", void 0), a([m(cc.SpriteFrame)], e.prototype, "frame_itemBtnNormal", void 0), a([m(cc.SpriteFrame)], e.prototype, "frame_itemBtnPressed", void 0), a([m([cc.SpriteFrame])], e.prototype, "frame_itemTextPressed", void 0), a([m([cc.SpriteFrame])], e.prototype, "frame_itemIconPressed", void 0), a([m(cc.Color)], e.prototype, "color_white", void 0), a([m(cc.Color)], e.prototype, "color_gray", void 0), a([m(cc.Node)], e.prototype, "node_content", void 0), a([m(cc.Prefab)], e.prototype, "pfb_item", void 0), a([f], e);
}(cc.Component);

o["default"] = _;

cc._RF.pop();